home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / Little Smalltalk v3.1.4 / C Source / Sources / tclprim.c < prev    next >
Text File  |  1995-01-26  |  20KB  |  766 lines

  1. /*
  2.     Little Smalltalk, version 3
  3.     Written by Tim Budd, Oregon State University, June 1988
  4.  
  5.     TCL window primitives
  6.     based on winprim.c written by tim budd, january 1989
  7.     
  8.     Changes for use with Symantec(TM) Think Class Library
  9.     and sundry fixes and enhancements by Julian Barkway, 
  10.     ⌐August 1994, all rights reserved.
  11.     
  12.     (TCL interface largely call-compatible with StdWin.)
  13. */
  14.  
  15. # include <stdio.h>
  16. # include <stdlib.h>
  17. # include <string.h>
  18. # include "env.h"
  19.  
  20. # include "glue.h"
  21.  
  22. # include "memory.h"
  23. # include "names.h"
  24.  
  25. # include <time.h>
  26. # include "macio.h"
  27. # include "memory.proto.h"
  28. # include "names.proto.h"
  29. # include "news.proto.h"
  30. # include "tclprim.proto.h"
  31.  
  32. extern object trueobj, falseobj;
  33. extern boolean parseok;
  34. extern int initial;
  35.  
  36. /* report a fatal system error */
  37. noreturn sysError(char *s1, char *s2)
  38. {    char buffer[1024];
  39.  
  40.     if (initial) {
  41.         ignore fprintf(stderr,"%s\n%s\n", s1, s2);
  42.  
  43.         }
  44.     else {
  45.         ignore sprintf(buffer,"%s %s", s1, s2);
  46.         wperror(buffer);
  47.         }
  48.     ignore abort();
  49. }
  50.  
  51. /* report a fatal system error */
  52. noreturn sysWarn(char *s1, char *s2)
  53. {    char buffer[1024];
  54.  
  55.     if (initial) {
  56.         ignore fprintf(stderr,"%s\n%s\n", s1, s2);
  57.         }
  58.     else {
  59.         ignore sprintf(buffer,"%s %s", s1, s2);
  60.         wperror(buffer);
  61.         }
  62. }
  63.  
  64. void compilWarn(char *selector, char *str1, char *str2)
  65. {    char buffer[1024];
  66.  
  67.     if (initial) {
  68.         ignore fprintf(stderr,"compiler warning: Method %s : %s %s\n", 
  69.             selector, str1, str2);
  70.         }
  71.     else {
  72.         ignore sprintf(buffer,"warn: %s %s", str1, str2);
  73.         wmessage(buffer);
  74.         }
  75. }
  76.  
  77. void compilError(char *selector, char *str1, char *str2)
  78. {    char buffer[1024];
  79.  
  80.     if (initial) {
  81.         ignore fprintf(stderr,"compiler error: Method %s : %s %s\n", 
  82.             selector, str1, str2);
  83.         }
  84.     else {
  85.         ignore sprintf(buffer,"error: %s %s", str1, str2);
  86.         wmessage(buffer);
  87.         }
  88.     parseok = false;
  89. }
  90.  
  91. noreturn dspMethod(char *cp, char *mp)
  92. {
  93.     /*ignore fprintf(stderr,"%s %s\n", cp, mp);*/
  94. }
  95.  
  96. void givepause(void)
  97. {    char buffer[80];
  98.  
  99.     if (initial) {
  100.         ignore fprintf(stderr,"push return to continue\n");
  101.         ignore gets(buffer);
  102.         }
  103.     else
  104.         wmessage("wait to continue");
  105. }
  106.  
  107. static object newPoint(int x, int y)
  108. {    object newObj;
  109.  
  110.     newObj = allocObject(2);
  111.     setClass(newObj, globalSymbol("Point"));
  112.     basicAtPut(newObj, 1, newInteger(x));
  113.     basicAtPut(newObj, 2, newInteger(y));
  114.     return newObj;
  115. }
  116.  
  117. static object newRect (short l, short t, short r, short b)
  118. {    
  119.     object newObj;
  120.  
  121.     newObj = allocObject (4);
  122.     setClass    (newObj, globalSymbol ("Rectangle"));
  123.     basicAtPut    (newObj, 1, newInteger (t));
  124.     basicAtPut    (newObj, 2, newInteger (l));
  125.     basicAtPut    (newObj, 3, newInteger (b));
  126.     basicAtPut    (newObj, 4, newInteger (r));
  127.     return newObj;
  128. }
  129.  
  130.  
  131. /* windows and text edit buffers are maintained in
  132.    a single structure */
  133.  
  134. /*   - retained for compatibility purposes. TextEdit pointers are now  */
  135. /*   stored as Smalltalk strings. Window pointers are unaffected - JRB */
  136.  
  137. # define WINDOWMAX 15
  138. static struct {
  139.     WINDOW *w;
  140.     TEXTEDIT *tp;
  141. } ws[WINDOWMAX];
  142.  
  143. /* All menu pointers are now stored as a character string */
  144. /* in the Smalltalk object itself - JRB                   */
  145.  
  146. /* current event record */
  147. static EVENT evrec;
  148.  
  149. static short openWindCount = 0;        /* No. of windows currently open */
  150. #define NO_WINDOWS        -1
  151.  
  152.  
  153. //========================================================================
  154. // Return the index of the currently active window.
  155. //========================================================================
  156. static int findWindow(WINDOW *w)
  157. {    
  158.     int i;
  159.     
  160.     if (openWindCount == 0)
  161.         return (NO_WINDOWS);
  162.         
  163.     for (i = 0; i < WINDOWMAX; i++)
  164.         if (w == ws[i].w)
  165.             return(i);
  166.             
  167. //****sysError ("can't find window","");  /* Is this really a fatal error? */
  168.     return (0);
  169. }
  170.  
  171.  
  172. //========================================================================
  173. // drawproc () is redundant but retained for compatibility purposes.
  174. //========================================================================
  175. static void drawproc(WINDOW *w, int left, int top, int right, int bottom)
  176. {    
  177.     return;
  178. }
  179.  
  180.  
  181. //========================================================================
  182. // Perform a TCL primitive.
  183. //========================================================================
  184. object sysPrimitive(int primitiveNumber, object *arguments)
  185. {    int i, j, k;
  186.     int p1, p2, p3, p4;
  187.     char *c;
  188.     WINDOW *w;
  189.     object returnedObject = nilobj;
  190.  
  191. //    A union is used in order to store menu and pane pointers in a Smalltalk 
  192. //    string, removing the need for an array in the C code.
  193.     union {
  194.         char        *charPtr;
  195.         TEXTEDIT    **tedt;
  196.         MENU        **menuPtr;
  197.         WINDOW        **winPtr;    /* Currently unused */
  198.         CURSOR        **csr;
  199.     } uu;
  200.     
  201.     TEXTEDIT    *te;
  202.  
  203.  
  204.     switch(primitiveNumber) {
  205.     case 160:                            /* window open */
  206. //    Extensively modified to accomodate window opening with 
  207. //      sizing parameters
  208.         {
  209.         short action, left, top, width, height;
  210.         i = intValue(arguments[0]);         /* win number */
  211.         if (ws[i].w)
  212.             break;                            /* already open */
  213.         action  = intValue (arguments [1]);    /* action */
  214.         c       = charPtr  (arguments[2]);  /* title */
  215.                                             /* win type (arguments[3]) not used */
  216.         switch (action) {
  217.             case 1:
  218.                 ws[i].w = w = wopen (c, NULL);
  219.                 break;
  220.             case 2:
  221.                 left    = intValue (arguments [4]);
  222.                 top     = intValue (arguments [5]);
  223.                 width   = intValue (arguments [6]);
  224.                 height  = intValue (arguments [7]);
  225.                 ws[i].w = w = wopentosize (c, left, top, width, height);
  226.                 break;
  227.         }
  228.         ws[i].tp = 0;
  229.         openWindCount++;
  230.         }
  231.         break;
  232.         
  233.     case 161:    /* variety of simple window actions */
  234.         i = intValue(arguments[0]); /* win number */
  235.         if (! (w = ws[i].w)) break;    /* return if no open */
  236.         j = intValue(arguments[1]); /* action */
  237.         switch(j) {
  238.             case 1: 
  239.                 ws[i].w = NULL; 
  240.                 wclose (w);
  241.                 openWindCount--; 
  242.                 break;
  243. /***********case 2: wbegindrawing(w); break;***/ /* Moved to prim 168 */
  244. /***********case 3: wenddrawing(w); break;*****/
  245.             case 4: wsetactive(w); break;
  246.             case 5: if (ws[i].tp) tedraw(ws[i].tp); break;
  247.             case 6:        /* Return the current size of the window */ 
  248.                 wgetwinsize(w, &i, &j); 
  249.                 returnedObject = newPoint(i, j); 
  250.                 break;
  251.             case 7:        /* Return the window's position in the global scheme of things */ 
  252.                 wgetwinpos (w, &i, &j);
  253.                 returnedObject = newPoint(i, j); 
  254.                 break;
  255.             case 8:        /* Bring the window to the front */    
  256.                 windowToFront (w); 
  257.                 break;
  258.             case 9:
  259.                 if (docDirty (w))
  260.                     returnedObject = trueobj;
  261.                 else
  262.                     returnedObject = falseobj;
  263.                 break;
  264.             case 10:    /* Set window title */
  265.                 c = charPtr (arguments[2]);
  266.                 wsettitle (w, (unsigned char *)c);
  267.                 break;
  268.         }
  269.         break;
  270.  
  271.     case 162:    /* one int arg actions */
  272.         i = intValue(arguments[0]); /* win number */
  273.         if (! (w = ws[i].w)) break;    /* return if no open */
  274.         i = intValue(arguments[1]); /* action */
  275.         if (i > 1)
  276.             uu.charPtr = charPtr (arguments [2]);    /* menuPtr */
  277.         else
  278.             j = intValue (arguments [2]); /* x */
  279.         switch(i) {
  280.             case 1:  /* set timer */
  281.                 wsettimer(w, j); break;
  282.             case 2:    /* menu attach */
  283.                 wmenuattach (w, *(uu.menuPtr)); 
  284.                 break;
  285.             case 3:    /* menu detach */
  286.                 wmenudetach (w, *(uu.menuPtr)); 
  287.                 break;
  288.         }
  289.         break;
  290.  
  291.     case 163:    /* two int arg actions */
  292.         i = intValue(arguments[0]); /* win number */
  293.         if (! (w = ws[i].w)) break;    /* return if no open */
  294.         i = intValue(arguments[1]); /* action */
  295.         j = intValue(arguments[2]); /* x */
  296.         k = intValue(arguments[3]); /* y */
  297.         switch(i) {
  298.             case 2: wsetdocsize(w, j, k); break;
  299.             case 3: wsetorigin(w, j, k); break;
  300.         }
  301.         break;
  302.  
  303.     case 164:    /* Cursors */
  304.         i = intValue(arguments[0]); /* Action */
  305.         switch (i) {
  306.             case 1:        /* Fetch a named cursor */
  307.                 c = charPtr (arguments [1]);
  308.                 returnedObject = newStString ("xxxx"); /* Allocate a four-byte string */
  309.                 uu.charPtr     = charPtr (returnedObject);
  310.                 *(uu.csr)      = wfetchcursor (c);    
  311.                 break;
  312.             case 2:        /* Show cursor */
  313.                 uu.charPtr = charPtr (arguments [1]);            /* CursPtr */
  314.                 wsetwincursor (NULL, *(uu.csr));    /* Window not used */
  315.                 break;
  316.             case 3:        /* Reset to default cursor (arrow) */
  317.                 setArrowCursor ();
  318.                 break;
  319.         }
  320.         break;
  321.  
  322.     case 165:    /* Some text-related functions */
  323.         uu.charPtr = charPtr (arguments [0]);            /* panePtr */
  324.         te       = *(uu.tedt);
  325.         j        = intValue (arguments[1]);            /* action */
  326.         switch  (j) {
  327.             case 1:
  328.                 returnedObject = newStString (tegettext (te));
  329.                 break;
  330.             case 2:
  331.                 returnedObject = newStString (teGetSelectedText (te));
  332.                 break;
  333.             case 3:                                    /* Replace all text with given text */
  334.                 c = charPtr (arguments [2]);
  335.                 replaceAllText (te, c);
  336.                 break;
  337.             case 4:                                    /* Delete all text in a pane */
  338.                 deleteAllText (te);
  339.                 break;
  340.             case 5:                                    /* Change font */
  341.                 c = charPtr (arguments [2]);
  342.                 setFont (te, c);
  343.                 break;
  344.             case 6:                                    /* Change point size */
  345.                 k = intValue (arguments [2]);
  346.                 setFontSize (te, k);
  347.                 break;
  348.             case 7:                                    /* Change type face */
  349.                 k = intValue (arguments [2]);
  350.                 setTypeFace (te, k);
  351.                 break;
  352.             case 8:                    /* Set the text selection to the given range */
  353.             {
  354.                 short    start, end;
  355.                 start = intValue (arguments [2]);
  356.                 end   = intValue (arguments [3]);
  357.                 setTextSelection (te, (long)start, (long)end);
  358.                 break;
  359.             }
  360.             case 9:                /* Return the start and end positions of a selection */
  361.             {
  362.                 long    start, end;
  363.                 getTextSelection (te, &start, &end);
  364.                 returnedObject = newPoint ((short)start, (short)end); 
  365.                 break;
  366.             }
  367.             case 10:        /* Scroll the text so that the current selection is visible */
  368.                 scrollToSelection (te);
  369.                 break;
  370.         }
  371.         break;
  372.  
  373.     case 166:    /* replace text */
  374.         uu.charPtr = charPtr (arguments [0]);            /* panePtr */
  375.         te       = *(uu.tedt);
  376.         tereplace (te, charPtr (arguments [1]));
  377. /*******tereplace (te, "\n");***//* Leave it up to the user to add a new line as required */
  378.         break;
  379.         
  380.     case 167:    /* get max screen area */
  381.     {
  382.         short    l, t, r, b;
  383.         getMaxScreenArea (&l, &t, &r, &b);
  384.         returnedObject = newRect (l, t, r, b);
  385.         break;
  386.     }
  387.  
  388.     case 168:    /* Window panes */
  389.     {
  390.         short         action, l, t, r, b, sh, sv, paneType, lineLength, protection;
  391.         
  392.         action   = intValue (arguments [0]);            /* action */
  393.         if (action == 1)
  394.             i = intValue (arguments [1]);                 /* win number */
  395.         else {
  396.             uu.charPtr = charPtr (arguments [1]);        /* panePtr */
  397.             te       = *(uu.tedt);
  398.         }
  399.         switch (action) {
  400.             case 1:                /* Attach a pane to a window */
  401.                 paneType = intValue (arguments [2]);     /* 1 - text, 2 - select, 3 - graphics */
  402.                 l        = intValue (arguments [3]);
  403.                 t        = intValue (arguments [4]);
  404.                 r        = intValue (arguments [5]);
  405.                 b        = intValue (arguments [6]);
  406.                 sh       = intValue (arguments [7]);
  407.                 sv       = intValue (arguments [8]);
  408.                 lineLength = intValue (arguments [9]);    /* in pixels */
  409.                 switch (paneType) {
  410.                     case 1:          /* Standard text */
  411.                         te = addTextPane (ws[i].w, l, t, r, b, sh, sv, lineLength);
  412.                         break;
  413.                     case 2:            /* Text selection pane */
  414.                         protection = intValue (arguments [10]); /* 0/1 - off/on */
  415.                         te = addSelPane (ws[i].w, l, t, r, b, sh, sv, lineLength);
  416.                         break;
  417.                     case 3:            /* Graphics */
  418.                         te = addGraphicsPane (ws[i].w, l, t, r, b, sh, sv);
  419.                         break;
  420.                 }
  421.                 returnedObject = newStString ("xxxx"); /* Allocate a four-byte string */
  422.                 uu.charPtr       = charPtr (returnedObject);
  423.                 *(uu.tedt)     = te;    /* then insert the te ptr using a union */
  424.                 break;
  425.             case 2:                /* Return current size of pane */
  426.                 getPaneSize (te, (short *)&i, (short *)&j);
  427.                 returnedObject = newPoint (i, j);
  428.                 break;
  429.             case 3:                /* Draw pane */
  430.                 paneType = intValue (arguments [2]);
  431.                 if (paneType != 3)
  432.                     tedraw (te);
  433.                 else 
  434.                     ;            /* Drawing handled by Smalltalk */
  435.                 break; 
  436.             case 4:
  437.                 wbegindrawing (te);    /* Changed from StdWin prototype to allow   */
  438.                 break;                /* output to be directed to different panes */
  439.             case 5:
  440.                 wenddrawing (te);
  441.                 break; 
  442.         }
  443.     }
  444.     
  445.         break;
  446.  
  447.     case 170: getevent:    /* get next event */
  448.         wgetevent(&evrec);
  449.         i = findWindow (evrec.window);
  450.         if (i > 0) {
  451.             if (ws[i].tp && teevent (ws[i].tp, &evrec))
  452.                 goto getevent;
  453.         }
  454.         returnedObject = newInteger (evrec.type);
  455.         break;
  456.  
  457.     case 171:    /* integer event info */
  458.         i = intValue(arguments[0]);
  459.         switch(i) {
  460.         case 1:     /* event window */
  461.             j = findWindow (evrec.window); 
  462.             if (j == NO_WINDOWS)
  463.                 j = 0;
  464.             break;
  465.         case 2:        /* event menu */
  466.             j = evrec.u.m.id; 
  467.             break;
  468.         case 3:        /* menu item */
  469.             j = evrec.u.m.item + 1; 
  470.             break;
  471.         case 4:        /* char typed */
  472.             j = evrec.u.character; 
  473.             break;
  474.         case 5:        /* mouse y */
  475.             j = evrec.u.where.v; 
  476.             break;
  477.         case 6:        /* mouse button */
  478.             j = evrec.u.where.button; 
  479.             break;
  480.         case 7:        /* mouse click number */
  481.             j = evrec.u.where.clicks; 
  482.             break;
  483.         case 8:        /* char typed */
  484.             j = evrec.u.character; 
  485.             break;
  486.         case 9:        /* command typed */
  487.             j = evrec.u.command; 
  488.             break;
  489.         }
  490.         returnedObject = newInteger(j);
  491.         break;
  492.  
  493.     case 172:    /* more general event info */
  494.         i = intValue(arguments[0]);
  495.         switch(i) {
  496.         case 1:        /* mouse down point */
  497.             returnedObject = newPoint(evrec.u.where.h, 
  498.                 evrec.u.where.v); 
  499.             break;
  500.         }
  501.         break;
  502.  
  503.     case 180:    /* new menu */
  504.         i = intValue (arguments [0]);     /* menu number */
  505.         c = charPtr  (arguments [1]);     /* title */
  506.         j = intValue (arguments [2]);     /* Pop-up menu? */
  507.         returnedObject = newStString ("xxxx");             /* Allocate a four-byte string */
  508.         uu.charPtr    = charPtr (returnedObject);
  509.         if (j)
  510.             *(uu.menuPtr) = popUpMenuCreate (i);
  511.         else
  512.             *(uu.menuPtr) = wmenucreate (i, c);
  513.         break;
  514.  
  515.     case 181:    /* menu item */
  516.         uu.charPtr = charPtr (arguments [0]);    /* menuPtr */
  517.         c          = charPtr (arguments [1]);   /* title */
  518.         if (isInteger (arguments[2]))
  519.             j = intValue (arguments[2]);
  520.         else 
  521.             j = -1;
  522.         wmenuadditem (*(uu.menuPtr), c, j);
  523.         break;
  524.  
  525.     case 182:    /* check menu items */
  526.         uu.charPtr = charPtr  (arguments [0]);    /* menuPtr */
  527.         j           = intValue (arguments [1]); /* item number */
  528.         k           = intValue (arguments [2]); /* action */
  529.         p1          = intValue (arguments [3]); /* flag */
  530.         switch (k) {
  531.             case 1:    /* enable/disable */
  532.                 wmenuenable (*(uu.menuPtr), j - 1, p1); break;
  533.             case 2: /* check/no check */
  534.                 wmenucheck (*(uu.menuPtr), j - 1, p1); break;
  535.         }
  536.         break;
  537.  
  538.     case 183:    /* Select from a pop-up menu */
  539.     {
  540.         short    menu, item;
  541.         
  542.         uu.charPtr = charPtr (arguments [0]);    /* menuPtr */
  543.         j = intValue (arguments [1]);             /* top */
  544.         k = intValue (arguments [2]);             /* left */
  545.         selectFromPopUpMenu (*(uu.menuPtr), j, k, &menu, &item);
  546.         returnedObject = newInteger (item); 
  547.         break;
  548.     }
  549.         
  550.     case 184:    /* Menu/Menu Item disposal */
  551.         uu.charPtr = charPtr  (arguments [0]);    /* menuPtr */
  552.         i           = intValue (arguments [1]); /* action */
  553.         switch (i) {
  554.             case 1:
  555.                 wmenudelete (*(uu.menuPtr));
  556.                 break;
  557.             case 2:
  558.                 k = intValue (arguments [2]); /* menu item number */
  559.                 removeMenuItem (*(uu.menuPtr), k);
  560.                 break;
  561.         }
  562.         break;
  563.  
  564.     case 190:    /* print text graphics */
  565.         i = intValue(arguments[0]); /* x */
  566.         j = intValue(arguments[1]); /* y */
  567.         c = charPtr(arguments[2]); /* text */
  568.         wdrawtext(i, j, c, strlen(c));
  569.         break;
  570.  
  571.     case 192:    /* points */
  572.         i = intValue(arguments[0]); /* action */
  573.         p1 = intValue(arguments[1]);
  574.         p2 = intValue(arguments[2]);
  575.         switch(i) {
  576.             case 1:  /* draw line */
  577.                 drawLineTo (p1, p2); break;
  578.             case 2:     /* Move to the given point */
  579.                 moveTo (p1, p2); break;
  580.             case 3:     /* Draw a pixel at the given point */
  581.                 drawPixel (p1, p2); break;
  582.         }
  583.         break;
  584.  
  585.     case 193:    /* circles and the like */
  586.         i = intValue(arguments[0]); /* action */
  587.         p1 = intValue(arguments[1]);
  588.         p2 = intValue(arguments[2]);
  589.         p3 = intValue(arguments[3]);
  590.         switch(i) {
  591.             case 1:        /* draw circle */
  592.                 wdrawcircle(p1,p2,p3); break;
  593.             case 2:        /* draw char */
  594.                 wdrawchar(p1,p2,p3); break;
  595.         }
  596.         break;
  597.  
  598.     case 194:    /* rectangles */
  599.         i = intValue(arguments[0]); /* action */
  600.         p1 = intValue(arguments[1]);
  601.         p2 = intValue(arguments[2]);
  602.         p3 = intValue(arguments[3]);
  603.         p4 = intValue(arguments[4]);
  604.         switch(i) {
  605.             case 1:        /* draw box */
  606.                 wdrawbox(p1,p2,p3,p4); break;
  607.             case 2:     /* paint */
  608.                 wpaint(p1,p2,p3,p4); break;
  609.             case 3:        /* erase */
  610.                 werase(p1,p2,p3,p4); break;
  611.             case 4:        /* invert */
  612.                 winvert(p1,p2,p3,p4); break;
  613.         }
  614.         break;
  615.  
  616.     case 195:    /* shading */
  617.         i = intValue(arguments[0]); /* action */
  618.         p1 = intValue(arguments[1]);
  619.         p2 = intValue(arguments[2]);
  620.         p3 = intValue(arguments[3]);
  621.         p4 = intValue(arguments[4]);
  622.         j = intValue(arguments[5]);
  623.         switch(i) {
  624.             case 1:        /* shading */
  625.                 wshade(p1,p2,p3,p4,j); break;
  626.             }
  627.         break;
  628.  
  629.     case 200:    /* issue a message */
  630.         c = charPtr(arguments[0]);
  631.         wmessage(c);
  632.         break;
  633.  
  634.     case 201:    /* ask a question */
  635.         { 
  636.         char replybuffer[120];
  637.         
  638.         strcpy (replybuffer, charPtr (arguments[1]));
  639.         if ( waskstr (charPtr (arguments[0]), replybuffer, 120) )
  640.             returnedObject = newStString (replybuffer);
  641.         else
  642.             returnedObject = newStString ("\0");
  643.         }
  644.         break;
  645.     
  646.     case 202:    /* ask a binary question */
  647.         i = waskync(charPtr(arguments[0]), intValue(arguments[1]));
  648.         if (i == 1)
  649.             returnedObject = trueobj;
  650.         else if (i == 0) 
  651.             returnedObject = falseobj;
  652.         break;
  653.  
  654.     case 203:    /* ask for a file - changed to allow specification of one of three */
  655.         {         /* file types to use to mask out types that aren't required */
  656.         char replybuffer [120];
  657.         
  658.         strcpy (replybuffer, charPtr (arguments [1]));
  659.         if ( waskfile (charPtr  (arguments [0]), replybuffer, 120, 
  660.                        intValue (arguments [2]), intValue (arguments [3])) )
  661.             returnedObject = newStString (replybuffer);
  662.         else
  663.             returnedObject = nilobj;
  664.         }
  665.         break;
  666.  
  667.     case 204:    /* error message */
  668.         wperror(charPtr(arguments[0]));
  669.         break;
  670.         
  671.     case 205:    /* beep */
  672.         wfleep();
  673.         break;
  674.  
  675.     case 206:    /* Save/Load text pane contents */
  676.         {
  677.         short     action, fileNum;
  678.         
  679.         uu.charPtr = charPtr (arguments [0]);        /* panePtr */
  680.         te       = *(uu.tedt);
  681.         action   = intValue (arguments [1]);    /* action */
  682.         fileNum  = intValue (arguments [2]);    /* file number - file must be open */
  683.         if (action)
  684.             saveTE (te, fileNum);
  685.         else
  686.             loadTE (te, fileNum);
  687.         break;
  688.         }
  689.     
  690.     case 207:    /* Get file info after receipt of an Open Document event */
  691.                 /* Returns full path with Smalltalk file type prepended  */
  692.                 /* (for drag'n'drop support).                             */
  693.     {
  694.         char    fullPath [255], str [255];
  695.         long    fType;
  696.         short    ft;
  697.         
  698.         if (getFileInfo (fullPath, &fType)) {
  699.             macFileTypeToSt (fType, ft);
  700.             sprintf (str, "%d%s", ft, fullPath); 
  701.             returnedObject = newStString (str);
  702.         }
  703.         else
  704.             returnedObject = nilobj;
  705.     }
  706.         
  707.     case 210:    /* Date and time functions */
  708. //      Uses 'standard' C date'n'time functions but I've a feeling that Symantec/Think C
  709. //      goes its own way on this one so they may not be as standard as you'd think....
  710.     {
  711.         time_t        cDateTime;
  712.         struct tm    *theTime;
  713.         char        str [30];
  714.         
  715.         time (&cDateTime);
  716.         theTime = localtime (&cDateTime);
  717.         i = intValue(arguments[0]); /* action */
  718.         switch (i) {
  719.             case 1:            /* Current date and time (string) */
  720.                 returnedObject = newStString (asctime (theTime));
  721.                 break;
  722.             case 2:            /* Day of week (numeric) */
  723.                 strftime (str, 30, "%w", theTime);
  724.                 j = (atoi (str)) + 1;
  725.                 returnedObject = newInteger (j);
  726.                 break;
  727.             case 3:            /* Day of month numeric) */
  728.                 strftime (str, 30, "%d", theTime);
  729.                 returnedObject = newInteger (atoi (str));
  730.                 break;
  731.             case 4:            /* Month number */
  732.                 strftime (str, 30, "%m", theTime);
  733.                 returnedObject = newInteger (atoi (str));
  734.                 break;
  735.             case 5:            /* Year (4 digits) */
  736.                 strftime (str, 30, "%Y", theTime);
  737.                 returnedObject = newInteger (atoi (str));
  738.                 break;
  739.         }
  740.         break;
  741.     }
  742.  
  743.     case 254:
  744.     {
  745.         char    str [30];
  746.         getVersionNumber (str);        
  747.         returnedObject = newStString (str);
  748.         break;
  749.     }
  750.     
  751.     case 255:    /* set debug */
  752.         i = intValue(arguments[0]); /* action */
  753.         if (i)                        /* Changed to allow debugging to be switched */
  754.             debugging = true;        /* on and off as required */
  755.         else
  756.             debugging = false;
  757.         break;
  758.  
  759.     default:
  760.         fprintf (stderr, "primitive not implmented yet %d\n", primitiveNumber);
  761.         sysError("primitive not done","");
  762.     }
  763.     return returnedObject;
  764. }
  765.  
  766.